#!/bin/bash
cat > /etc/netplan/00-installer-config.yaml << EOF
network:
  ethernets:
    ens18:
      dhcp4: no
      addresses: [192.168.2.251/24]   # 设置静态IP地址及子网掩码
      gateway4: 192.168.2.1     # 设置默认网关
      nameservers:
        addresses: [114.114.114.114,8.8.8.8, 8.8.4.4]   # 设置DNS服务器

  version: 2
EOF


#刷新网络
netplan apply










